#include "ShareMemory.h"

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

#include <sys/types.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <signal.h>
#include <sys/shm.h>
void main()
{
    pid_t pid=fork();
    if(pid<0)
    {
        perror("fork");
        return;
    }
    if(pid==0)
    {
        ShMemory *shm=InitShareMemory("./",10,1024);
        char temp[20]="helloworld";
        WriteToShareMemory(shm,temp,20);
    }
    else
    {
        wait(NULL);
        ShMemory *shm=InitShareMemory("./",10,1024);
        char temp[20]={0};
        ReadFormShareMemory(shm,temp,20);
        printf("read:%s\n",temp);
        ClearShareMemory(shm);
    }
    
}